<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html;charset=utf-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <%@ include file="/assets/public.jsp"%>

    <title>发布会议</title>
    <style>
        /*这个是这页面特有的，需要单独写出来*/
        .myTitle > input{
            float: right;
            margin-left: 15px;
        }

    </style>
</head>
<body>
<%@include file="/assets/header.jsp"%>

<div class="d-flex align-items-stretch">
    <!-- Sidebar Navigation-->
    <%@ include file="/assets/side.jsp"%>
    <!-- Sidebar Navigation end-->
    <div class="page-content">
        <div class="page-header">
            <div class="container-fluid">
                <h2 class="h5 no-margin-bottom">发布会议</h2>
            </div>
        </div>

        <section class="no-padding-bottom">

            <div class="block-body">
                <div class="form-group">
                    <label class="form-control-label">标题</label>
                    <input type="text" id="title" placeholder="会议标题" class="form-control">
                </div>
                <!--选择部门-->
                <div class="form-group">
                    <label class="form-control-label">部门：</label>
                    <select id="dept_name"  class="selectpicker" data-live-search="true">
                        <c:forEach items="${depts}" var="dept">
                            <option value="${dept.id}">${dept.name}</option>
                        </c:forEach>
                    </select>
                    <button id="userClick" class="btn btn-primary">抄送人</button>
                    <select id="make_user" class="selectpicker" data-live-search="true" multiple>
                        <c:forEach items="${sessionScope.usersBydId}" var="user">
                            <option value="${user.id}">${user.realName}</option>
                        </c:forEach>
                        <option></option>
                    </select>
                </div>
                <!--开始时间-->
                <div class="form-group">
                    <label class="form-control-label">开始时间</label>

                    <input type="text" class="form-control" id="startTime" data-date-format="yyyy-mm-dd hh:ii:ss">
                </div>
                <!--结束时间-->
                <div class="form-group">
                    <label class="form-control-label">结束时间</label>

                    <input type="text" class="form-control" id="endTime" data-date-format="yyyy-mm-dd hh:ii:ss">
                </div>
                <div class="form-group">
                    <label class="form-control-label">会议内容</label>
                    <textarea id="content" class="form-control" rows="5"></textarea>
                </div>
                <div class="text-center form-group">
                    <input id="path" type="hidden" value="${pageContext.request.contextPath}" />
                    <input id="sub" type="button" value="发布" class="btn btn-primary">
                    <input type="reset" value="清空" class="btn btn-info">
                </div>
            </div>
        </section>

        <%@include file="/assets/footer.jsp"%>
    </div>
</div>

<script>
$(function () {
	$('#startTime').datetimepicker();
    $('#endTime').datetimepicker();
    var path = $("#path").val();

    $("#sub").click(function () {
        var arr = [];//定义一个数组
        arr = $("#make_user").val();
        console.log(arr);
        $.ajax({
            url:path + '/meeting/saveMeeting?arr=' + arr,
            type:'post',
            data:{
                title:$("#title").val(),
                deptId:$("#dept_name").val(),
                make_user:arr,
                startTime:$("#startTime").val(),
                endTime:$("#endTime").val(),
                content:$("#content").val()
            },
            success:function (data) {
                if (data === "0"){
                    layer.msg("发布成功,3秒后返回原页面");
                    setTimeout(function () {
                        location.href = path + "/meeting/findMeeting";
                    },3000);
                }
                else {
                    layer.msg("发布失败");
                }
            }
        })
    });

    $("#userClick").click(function () {
        console.log($("#dept_name").val());
        $.ajax({
            url:path + '/meeting/updateSelect',
            type:'post',
            data:{
                deptId:$("#dept_name").val()
            },
            success:function (data) {

            }
        });
    });
})
</script>
</body>
</html>